#! /bin/csh -f 

##########################################################
#
#       Check Operating System version #
#
##########################################################

setenv OSVERSION `/sbin/uname -r`

@ ver = `/sbin/uname -r | cut -c1,3`
setenv OSVER $ver

if ($ver <= 52 || $ver == 60 || $ver >= 65)  then
        set answer = `$HOTMIXDIR/.bin/wrongOS`
        if ($answer == 0) then 
                echo " "
                echo "EXITing, Good-Bye"
                echo " "
                exit 0
        endif
endif

##########################################################
#
#       Set envir variables
#
##########################################################

unalias *
alias cd cd
set filec
setenv USERNAME `/usr/bin/whoami`
setenv HOSTNAME `/sbin/uname -n`
setenv DOMAINNAME `$HOTMIXDIR/.bin/domainname`

##########################################################
#
#	Search Engine Stuff
#
##########################################################

sed s:setup.csh:$HOTMIXDIR/html/setup.csh: $HOTMIXDIR/html/searchsetup.html > /usr/tmp/tempsearch.html
sed s:searchinfo.html:$HOTMIXDIR/html/searchinfo.html: /usr/tmp/tempsearch.html > /usr/tmp/hm17search.html
rm -f /usr/tmp/tempsearch.html
cp $HOTMIXDIR/html/statsear.jpg /usr/tmp/statsear.jpg

##########################################################
#
#      NEED to find a writeable tmp directory
#
##########################################################

        if (-w /usr/tmp) then
           setenv TMPFILEDIR "/usr/tmp"
        else if (-w /tmp) then
           setenv TMPFILEDIR "/tmp"
        else if (-w $HOME) then
           setenv TMPFILEDIR $HOME
        endif

setenv SHOWMESS $HOTMIXDIR/.bin/showmess

set path=($HOTMIXDIR/.bin /usr/bin/X11 /usr/sbin . $TMPFILEDIR $path)

##########################################################
#
#       Tell user that this may load slow the first time #
#
##########################################################

if !(-e "$HOME/.netscape/preferehm17") then
	set garbage=`/usr/bin/X11/xconfirm -icon info -t "Hot Mix 17 is loading Netscape 3 from the CD. This may take a few moments to load the first time you use the CD." \
-t " "  \
-t "Press continue." -B Continue` &

endif

##########################################################
#
#       Set the (app-defaults, X-resources, $path) paths 
#
##########################################################

if ( ! ${?XUSERFILESEARCHPATH} ) then
	if ("$HOME" == "/") then
		setenv XUSERFILESEARCHPATH "/.desktop-`hostname`/%N:/tmp/.hotmix/app-defaults/%N:/tmp/.hotmix/app-defaults/%N%C:$HOME/%N:/usr/lib/X11/app-defaults/%N:/usr/lib/X11/app-defaults/%L/%N%C:/usr/lib/X11/app-defaults/%l/%N%C:/usr/lib/X11/app-defaults/%N%C:/usr/lib/X11/app-defaults/%L/%N:/usr/lib/X11/app-defaults/%l/%N"
	else
		setenv XUSERFILESEARCHPATH "$HOME/.desktop-`hostname`/%N:/tmp/.hotmix/app-defaults/%N:/tmp/.hotmix/app-defaults/%N%C:$HOME/%N:/usr/lib/X11/app-defaults/%N:/usr/lib/X11/app-defaults/%L/%N%C:/usr/lib/X11/app-defaults/%l/%N%C:/usr/lib/X11/app-defaults/%N%C:/usr/lib/X11/app-defaults/%L/%N:/usr/lib/X11/app-defaults/%l/%N"
	endif
else
	if ("$HOME" == "/") then
		setenv XUSERFILESEARCHPATH "/.desktop-`hostname`/%N:/tmp/.hotmix/app-defaults/%N:/tmp/.hotmix/app-defaults/%N%C:/%N:/usr/lib/X11/app-defaults/%N:/usr/lib/X11/app-defaults/%L/%N%C:/usr/lib/X11/app-defaults/%l/%N%C:/usr/lib/X11/app-defaults/%N%C:/usr/lib/X11/app-defaults/%L/%N:/usr/lib/X11/app-defaults/%l/%N:${XUSERFILESEARCHPATH}"
	else
		setenv XUSERFILESEARCHPATH "$HOME/.desktop-`hostname`/%N:/tmp/.hotmix/app-defaults/%N:/tmp/.hotmix/app-defaults/%N%C:/%N:/usr/lib/X11/app-defaults/%N:/usr/lib/X11/app-defaults/%L/%N%C:/usr/lib/X11/app-defaults/%l/%N%C:/usr/lib/X11/app-defaults/%N%C:/usr/lib/X11/app-defaults/%L/%N:/usr/lib/X11/app-defaults/%l/%N:${XUSERFILESEARCHPATH}"
	endif
endif


##########################################################
#
#       Set path for libraries
#
##########################################################

setenv NPX_PLUGIN_PATH /usr/local/lib/netscape/plugins

setenv CLASSPATH $HOTMIXDIR/.bin/netscape/classes:.

if ( ! ${?LD_LIBRARY_PATH} ) then
	setenv LD_LIBRARY_PATH /usr/lib:/lib:/lib/cc:/usr/lib/cc:/usr/local/lib:.
endif

if ( ! ${?LD_LIBRARYN32_PATH} ) then
	setenv LD_LIBRARYN32_PATH /usr/lib32:/lib32
endif

if ( ! ${?LD_LIBRARY64_PATH} ) then
	setenv LD_LIBRARYN32_PATH /usr/lib64:/lib64
endif

##########################################################
#
#       Set environ for netscape
#
##########################################################

LOOP:
if (-e "$HOME/.netscape/") then
  if (-w "$HOME/.netscape/") then
        if (-e "$HOME/.netscape/preferences") then
                nawk -f $HOTMIXDIR/.bin/awkzilla.awk \
				       $HOME/.netscape/preferences \
				     > $HOME/.netscape/preferehm17
                chmod 777 $HOME/.netscape/preferehm17
        else
                nawk -f $HOTMIXDIR/.bin/awkzilla.awk \
			$HOTMIXDIR/.bin/netscape/preferehm17 \
			> $HOME/.netscape/preferehm17
                chmod 777 $HOME/.netscape/preferehm17
        endif

# add some logic here about  and if it is imgtools 3.0
	if ($ver != 62 )  then
	nawk -f $HOTMIXDIR/.bin/awkzilla3.awk \
                $HOME/.netscape/preferehm17 \
                > $HOME/.netscape/preferehm17.new
        cp $HOME/.netscape/preferehm17.new $HOME/.netscape/preferehm17
	endif


	if (! -e "$HOME/.netscape/java_301") then
		cp $HOTMIXDIR/.bin/netscape/java_301 $HOME/.netscape/
	endif

  else 
	/usr/bin/X11/xconfirm -icon warning \
        -t "Cannot Write to the $HOME/.netscape directory" \
        -t " " \
        -t "You need to have write permissions for the $HOME/.netscape home directory\!" \
        -t "This will end this session of Hot Mix...." \
        -t " " \
        -b Ok
        exit 
  endif
else
  if (-w $HOME) then
        mkdir $HOME/.netscape/
       	if (-e "$HOME/.netscape-preferences") then
        	setenv ORIGSOCKSHOSTS `grep SOCKS_HOST $HOME/.netscape-preferences|awk '{print $2}'`
        	echo ORIGSOCKSHOSTS=$ORIGSOCKSHOSTS
        	nawk -f $HOTMIXDIR/.bin/awkzilla2.awk \
        		$HOTMIXDIR/.bin/netscape/preferehm17 \
        		> $HOME/.netscape/preferences
        endif
        goto LOOP
  else 
        /usr/bin/X11/xconfirm -icon warning \
        -t "Cannot Write to the $HOME directory" \
        -t " " \
        -t "You need to have write permissions for the $HOME directory\!" \
        -t "This will end this session of Hot Mix...." \
        -t " " \
        -b Ok
        exit
  endif 
endif

##########################################################
#
#       Add /tmp/.hotmix/netscape
#
##########################################################

if ( -w /tmp && ! -e /tmp/.hotmix/app-defaults) then
	mkdir /tmp/.hotmix
	cp -r $HOTMIXDIR/.bin/netscape/app-defaults /tmp/.hotmix
	cp $HOTMIXDIR/.bin/netscape/animation.dat /tmp/.hotmix
endif

if ( -r /tmp/.hotmix/app-defaults/Netscape.cfg && -r /tmp/.hotmix/app-defaults/Netscape ) then

cd $HOME

	$HOTMIXDIR/.bin/netscape/netscape.lock -geometry 878x823 -xrm "*strings.22130:This process will either Install, Launch or Remove\nsoftware from the Hot Mix 17 CD.\n\nProceed?\n" file:$HOTMIXDIR/html/index.html
else
	$HOTMIXDIR/.bin/netscape/netscape -geometry 878x823 -xrm "*strings.22130:This process will either Install, Launch or Remove\nsoftware from the Hot Mix 17 CD.\n\nProceed?\n" file:$HOTMIXDIR/html/index.html
endif

##########################################################
#
#       Clean up
#
##########################################################

exit

